﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="tur3", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Tur3))]
    public class Tur3Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ITur3 clazz;
        
        public Tur3Serializer(ITur3 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("orgform");
            if (clazz.Orgform!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Orgform))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Orgform");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("totalbet");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Totalbet))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("totalrake");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Totalrake))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("totalpayo");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Totalpayo))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="orgform") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>tur3>orgform");
                }
                clazz.Orgform = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("orgform")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>tur3>orgform", Reader.LocalName);
            }
            if (Reader.LocalName=="totalbet") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>tur3>totalbet");
                }
                clazz.Totalbet = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("totalbet")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>tur3>totalbet", Reader.LocalName);
            }
            if (Reader.LocalName=="totalrake") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>tur3>totalrake");
                }
                clazz.Totalrake = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("totalrake")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>tur3>totalrake", Reader.LocalName);
            }
            if (Reader.LocalName=="totalpayo") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>tur3>totalpayo");
                }
                clazz.Totalpayo = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("totalpayo")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>tur3>totalpayo", Reader.LocalName);
            }
        }
    }
}
